package com.khotyn.heresy.controller;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.khotyn.heresy.bean.Admin;
import com.khotyn.heresy.dao.AdminDAO;

@Controller
@RequestMapping("/admin.html")
public class AdminController {
	@Autowired
	private AdminDAO adminDAO;
	
	@RequestMapping(method = RequestMethod.GET)
	public ModelAndView onLoad(HttpSession session){
		Integer adminID = (Integer) session.getAttribute("adminID");
		Admin admin = new Admin();
		admin.setAdminID(adminID);
		admin = adminDAO.selectAdminByID(admin);
		return new ModelAndView("admin", "admin", admin);
	}
}
